#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
  chdir("/home/xyc/");
  FILE *fp = fopen("log.txt", "w");
  if(!fp)
  {
    perror("fopen error!");
    return -1;
  }
  const char *msg = "hello world!\n";
  int count = 5;
  int n = 0;
  while(count--)
  {
    n = fwrite(msg, strlen(msg), 10, fp);
    printf("write %d block, pid:%d\n",n,getpid());
    sleep(20);
  }
  fclose(fp);
  return 0;
}

